import request from "@/utils/request";
import axios from "axios";

export function listOldAnswere(data) {
  // 获取历史问题接口
  return request({
    url: "/api/getAnsweredQuestion",
    method: "post",
    data
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // }
  });
}

export function submitAnswere(data) {
  // 单选程序答案提交接口
  return request({
    url: "/api/receiveWrongMsg",
    method: "post",
    data
  });
}

export function homework(data) {
  // 课后作业数据接口
  return request({
    url: "/api/homework",
    method: "post",
    data
  });
}
export function learnTime(data) {
  // 定时调用,用于计算用户学习时间
  return request({
    url: "/api/learnTime",
    method: "post",
    data
  });
}

export function getQuestionTotal(data) {
  // 根据问题id获取问题
  return request({
    url: "/api/getQuestionTotal",
    method: "post",
    data
  });
}

export function codeRun(data) {
  // 调用代码运行接口
  return axios({
    url: 'http://localhost:8080/getResult',
    // url: '/codeApi/getResult',
    // url: "/api/runcode",
    method: "post",
    data,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    transformResponse: [function (data) {
      return data;
    }]
  });
}
